/*
 * @Author: 谢小康 2170673706@qq.com
 * @Date: 2023-11-21 17:06:33
 * @LastEditors: 谢小康 2170673706@qq.com
 * @LastEditTime: 2024-01-27 10:46:31
 * @FilePath: \My-bolg\server\router\article.js
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
let express = require('express');
let router = express.Router();
const {
    validataarticlename,
    getarticle,
    addarticle,
    getRecyclelist,
    toToparticle,
    getarticlebyid,
    edmitarticle,
    editfileName,
    cancelToparticle,
    deleteArticle,
    getarticlebycondition,
    getposlistarticle,
    subposition,
    getAllowTotops,
    getPreAndnext,
    addarticleview,
    getrecommentdarticle,
    getarticlenum,
    getarticlebypos,
    addlike,
    serchinfo
} = require('../controller/article');
const {
    verifyArticleParam,
    everfySherchprams,
    addpos
} = require("../middleware/article.js")
const { auth } = require('../util/user');
const {isSuperAdmin} = require('../controller/user.js')
/* 全部 */
/* 分页获取文章 */
router.post("/getarticle",getarticle)
/* 根据文章id查询文章内容 */
router.get("/getarticlebyid",getarticlebyid)

/* -----------------------------------------------------------后台接口--------------------------- */                                                           
/* 校验文章名字 */
router.get('/validataarticlename',validataarticlename)
/* 添加文章 */
router.post("/addarticle",auth,verifyArticleParam,isSuperAdmin,addarticle)
/* 分页获取草稿箱 */
router.post("/getrecyclelist",auth,getRecyclelist)
/* 置顶文章 */
router.post("/totoparticle",auth,isSuperAdmin,toToparticle)
/* 取消文章置顶 */
router.post("/cancelToparticle",auth,isSuperAdmin,cancelToparticle)
/* 编辑文章 */
router.post("/edmitarticle",auth,isSuperAdmin,edmitarticle)
/* 编辑文章上传文章的封面 */
router.post("/editfileName",auth,isSuperAdmin,editfileName)
/* 删除文章 */
router.post("/deleteArticle",auth,isSuperAdmin,deleteArticle)
/* 条件加分页搜索文章 */
router.post("/getarticlebycondition",auth,getarticlebycondition)
/* 获取文章的地点 */
router.post("/getposlistarticle",auth,getposlistarticle)
/* 添加足迹 */
router.post("/subposition",auth,isSuperAdmin,addpos,subposition)
/* 查看是否可以置顶 */
router.get("/getAllowTotop",auth,isSuperAdmin,getAllowTotops)
/* ------------------------------------------------------------------------------------------------------------------------ */

                                                            /* 前台接口 */
/* 获取上一篇下一篇文章 */
router.get("/getPreAndnext",getPreAndnext)
/* 添加访问量 */
router.get("/addarticleview",addarticleview)
/* 获取推荐文章 */
router.get("/getrecommentdarticle",getrecommentdarticle)
/* 获取文章数量 */
router.get("/getarticlenum",getarticlenum)
/* 获取地址和文章 */
router.get("/getarticlebypos",getarticlebypos)
/* 添加赞 */
router.post("/addlike",addlike)
router.post("/search",serchinfo)
module.exports = router;
